package com.redtrusssoftware.truckloaderpro;

import java.util.ArrayList;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CustomAdapterTruck extends BaseAdapter{
	
	private static ArrayList<Truck> truckList;
	
	private LayoutInflater mInflater;
	
	public CustomAdapterTruck(Context context, ArrayList<Truck> trucks){
		truckList = trucks;
		mInflater = LayoutInflater.from(context);
				
	}
	
	public int getCount(){
		return truckList.size();
	}
	
	@Override
	public Object getItem(int position){
		return truckList.get(position);
	}
	
	@Override
	public long getItemId(int position){
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			   convertView = mInflater.inflate(R.layout.customrowtruck, null);
			   holder = new ViewHolder();
			   holder.name = (TextView) convertView.findViewById(R.id.name2);

			   convertView.setTag(holder);
			  } else {
			   holder = (ViewHolder) convertView.getTag();
			  }
			  
			  holder.name.setText(truckList.get(position).getName());

			  return convertView;
	}
	
	
	
	static class ViewHolder{
		TextView name;
	}

}
